package src.main.kotlin.day09


/**
 * 枚举类3
 *  代数数据类型： 可以表示一组子类型的闭集，枚举类就是简单的ADT
 */
fun main() {
    val driver = Driver(LicenseStatus.LEARNING)
    println(driver.checkLicense())
    println(driver is Any)
}

enum class LicenseStatus{
    UNQUALIFIED,
    LEARNING,
    QUALIFIED;
}

class Driver(private var status:LicenseStatus){
    fun checkLicense():String{
        //不使用else语句，编译器可以帮助检查代码处理是否有遗漏
        return when(status){
            LicenseStatus.UNQUALIFIED -> "没资格"
            LicenseStatus.LEARNING -> "在学"
            LicenseStatus.QUALIFIED -> "有资格"
            else->"未知"
        }

    }
}

